import { CLOUD_ADOPT_ORDER_DICT, COMBO_LIST } from '@/const/type';
const PAY_TYPE_DIC = [
  {
    label: '订购',
    value: '1',
  },
  {
    label: '手动续费',
    value: '2',
  },
  {
    label: '自动续费',
    value: '3',
  },
];

const PAY_STATUS_DIC = [
  {
    label: '未支付',
    value: '1',
  },
  {
    label: '支付成功',
    value: '2',
  },
  {
    label: '支付失败',
    value: '3',
  },
  {
    label: '支付取消',
    value: '4',
  },
];

export const tableOption = {
  ...window.$crudMixins.tableOptions,
  addBtn: false,
  editBtn: false,
  delBtn: false,
  menuWidth: 240,
  viewBtn: false,
  column: [
    {
      label: '订单编号',
      prop: 'orderCode',
      width: 180,
    },
    {
      label: '云认养用户',
      prop: 'userName',
      search: true,
      searchLabelWidth: 120,
      width: 150,
      slot: true,
      searchOrder: 4,
    },
    {
      label: '下单时间',
      prop: 'createTime',
      type: 'date',
      hide: true,
      search: true,
      format: 'yyyy-MM-dd HH:mm:ss',
      valueFormat: 'yyyy-MM-dd HH:mm:ss',
      searchRange: true,
      searchSpan: 6,
    },
    {
      label: '手机号',
      prop: 'phone',
      search: true,
      width: 120,
    },
    {
      label: '宠物昵称',
      prop: 'petName',
      search: true,
      width: 120,
      searchOrder: 3,
    },
    {
      label: '宠物ID',
      prop: 'petId',
      slot: true,
      search: true,
      searchOrder: 2,
      width: 150,
    },
    {
      label: '实付金额',
      prop: 'paidAmount',
      formatter: (row) => {
        return `￥${row.paidAmount}`;
      },
    },
    {
      label: '订单来源',
      prop: 'clientType',
      type: 'select',
      dicData: [
        {
          label: 'APP',
          value: 'APP',
        },
        {
          label: '抖音小程序',
          value: 'DOUYIN_MP',
        },
        {
          label: '微信小程序',
          value: 'WECHAT_MP',
        },
      ],
    },
    {
      label: '订单状态',
      prop: 'status',
      search: true,
      type: 'select',
      searchOrder: 1,
      width: 80,
      dicData: CLOUD_ADOPT_ORDER_DICT,
    },
    {
      label: '流水记录',
      prop: 'tradeNum',
    },
    {
      label: '下单时间',
      prop: 'createTime',
      width: 150,
    },
    {
      label: '云养开始时间',
      prop: 'startTime',
      width: 150,
    },
    {
      label: '云养到期时间',
      prop: 'endTime',
      width: 150,
    },
    {
      label: '结束订单时间',
      prop: 'endTime',
      width: 150,
    },
  ],
};
///交易流水
export const tradeFlowOption = {
  ...window.$crudMixins.tableOptions,
  addBtn: false,
  editBtn: false,
  delBtn: false,
  menu: false,
  viewBtn: false,
  column: [
    {
      label: '交易流水编号',
      prop: 'orderCode',
      width: 180,
    },
    {
      label: '支付类型',
      prop: 'payType',
      type: 'select',
      dicData: PAY_TYPE_DIC,
    },
    {
      label: '支付金额',
      prop: 'payAmount',
      formatter: (row) => {
        return `￥${row.payAmount || 0}`;
      },
    },
    {
      label: '支付方式',
      prop: 'paymentMethod',
    },
    {
      label: '交易单号',
      prop: 'payNo',
    },
    {
      label: '套餐类型',
      prop: 'packageType',
      type: 'select',
      dicData: COMBO_LIST,
    },
    {
      label: '支付周期',
      prop: 'packagePeriod',
      formatter: (row) => {
        return `${row.packagePeriod}${
          row.packagePeriodUnit === '1' ? '个月' : '年'
        }`;
      },
    },
    {
      label: '支付状态',
      prop: 'payStatus',
      dicData: PAY_STATUS_DIC,
    },
    {
      label: '支付成功时间',
      prop: 'payTime',
      width: 160,
    },
    {
      label: '云养开始时间',
      prop: 'adoptStartTime',
      width: 160,
    },
    {
      label: '云养到期时间',
      prop: 'adoptEndTime',
      width: 160,
    },
  ],
};
// 停止订单
export const pauseOrderFormOption = {
  labelWidth: 160,
  submitBtn: false,
  emptyBtn: false,
  column: [
    {
      label: '订单停止原因',
      prop: 'stopReason',
      formslot: true,
      row: true,
      span: 24,
      rules: [
        {
          required: true,
          message: '请选择订单停止原因',
          trigger: 'blur',
        },
      ],
    },
    {
      label: '实际云养结束日期',
      prop: 'adoptStopTime',
      span: 24,
      type: 'datetime',
      formslot: true,
      rules: [
        {
          required: true,
          message: '请选择际云养结束日期',
          trigger: 'blur',
        },
      ],
    },
    {
      label: '订单退费类型',
      prop: 'refundType',
      type: 'radio',
      dicData: [
        {
          label: '线下退款',
          value: '1',
        },
        {
          label: '无需进行退款',
          value: '2',
        },
      ],
      rules: [
        {
          required: true,
          message: '请选择订单退费类型',
          trigger: 'blur',
        },
      ],
    },
    {
      label: '',
      prop: 'refundReason',
      span: 24,
      placeholder: '请详细描述线下退款/无需进行退款的情况',
      type: 'textarea',
    },
  ],
};

export const cloudStopReason = {
  labelWidth: 160,
  submitBtn: false,
  emptyBtn: false,
  detail: true,
  column: [
    {
      label: '订单停止原因',
      row: true,
      prop: 'stopReason',
    },
    {
      label: '停止订单日期',
      row: true,
      prop: 'orderStopTime',
    },
    {
      label: '实际云养结束日期',
      row: true,
      prop: 'stopTime',
    },
    {
      label: '订单退费类型',
      row: true,
      prop: 'refundType',
      type: 'select',
      dicData: [
        {
          label: '线下退款',
          value: '1',
        },
        {
          label: '无需进行退款',
          value: '2',
        },
      ],
    },
    {
      label: '订单退费说明',
      prop: 'refundReason',
      row: true,
    },
  ],
};
